/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Domain;

import java.util.Observer;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 *
 * @author kenneth
 */
public class DomainController {
    
    private static DomainController dc;
    private DropboxServer dpServer;
    private ObservableManager om;
    
    private DomainController() {
        
    }
    
    public static DomainController getDomainController() {
        if(dc == null) {
            dc = new DomainController();
        }
        return dc;
    }
    
    public void startServer(Observer observer) {
        ExecutorService threadExecutor;
        threadExecutor = Executors.newFixedThreadPool(1);
        om = new ObservableManager(observer);
        dpServer = new DropboxServer(om);
        threadExecutor.execute(dpServer);
    }
    
    
    public void stopServer() {
        dpServer.stopServer();
    }
    
    public boolean serverIsRunning() {
        return dpServer.isRunning();
    }
}
